//
//  AddyixiangController.m
//  Ten
//
//  Created by anfuer on 2018/11/1.
//  Copyright © 2018年 xg韦. All rights reserved.
//

#import "AddyixiangController.h"
#import "PickerToolView.h"
#import "YMCitySelect.h"

@interface AddyixiangController ()<YMCitySelectDelegate>
{
    NSArray*ary1;
    NSArray*ary2;
    NSArray*ary3;
    
}
@property (weak, nonatomic) IBOutlet UITextField *tsf1;
@property (weak, nonatomic) IBOutlet UITextField *tsf2;
@property (weak, nonatomic) IBOutlet UIButton *btn1o;
@property (weak, nonatomic) IBOutlet UIButton *btn2o;
@property (weak, nonatomic) IBOutlet UIButton *btn3o;
@property (weak, nonatomic) IBOutlet UIButton *btn4o;

@end

@implementation AddyixiangController

- (void)viewDidLoad {
    [super viewDidLoad];
    ary1= @[@"全职",@"兼职",@"实习"];
    ary2=@[@"在职",@"离职"];
    ary3=@[@"可立即上岗",@"一个月内可到岗"];
    
    
    if (_passdic) {
        [_btn1o setTitle:WXGStr(_passdic[@"type"]) forState:UIControlStateNormal];
        _tsf1.text=WXGStr(_passdic[@"position"]);
//        _tsf2.text=WXGStr(_passdic[@"position"]);
        [_btn2o setTitle:WXGStr(_passdic[@"city"]) forState:UIControlStateNormal];
         [_btn3o setTitle:WXGStr(_passdic[@"job_status"]) forState:UIControlStateNormal];
         [_btn4o setTitle:WXGStr(_passdic[@"post_time"]) forState:UIControlStateNormal];
    }
    
    // Do any additional setup after loading the view.
}
- (IBAction)SavaBtna:(UIButton *)sender {
    
    NSMutableDictionary*mdic=[NSMutableDictionary dictionary];
    [mdic setObject:_tsf1.text forKey:@"position"];
    [mdic setObject:_tsf2.text forKey:@"salary"];
    [mdic setObject:WXGStr(_passdic[@"id"]) forKey:@"id"];
    
    if (![[_btn1o currentTitle]isEqualToString:@"请选择"]) {
         [mdic setObject:[NSString stringWithFormat:@"%lu",(unsigned long)[ary1 indexOfObject:[_btn1o currentTitle]]+1] forKey:@"type"];
    }
    if (![[_btn2o currentTitle]isEqualToString:@"请选择"]) {
        [mdic setObject:[_btn2o currentTitle] forKey:@"city"];
    }
    if (![[_btn3o currentTitle]isEqualToString:@"请选择"]) {
        [mdic setObject:[NSString stringWithFormat:@"%lu",(unsigned long)[ary2 indexOfObject:[_btn3o currentTitle]]+1] forKey:@"job_status"];
    }
    if (![[_btn4o currentTitle]isEqualToString:@"请选择"]) {
        [mdic setObject:[NSString stringWithFormat:@"%lu",(unsigned long)[ary3 indexOfObject:[_btn4o currentTitle]]+1] forKey:@"post_time"];
    }
    [mdic setObject:_resume_id forKey:@"resume_id"];
    
    [FuncPublic getData:self parameters:mdic RequestUrl:edit_job_intension success:^(NSDictionary *acountInfo) {
       [WSProgressHUD showImage:nil status:acountInfo[@"msg"]];
    }];

}
- (IBAction)changgeBtna:(UIButton *)sender {
    if (sender==_btn2o) {
        [self presentViewController:[[YMCitySelect alloc] initWithDelegate:self] animated:YES completion:nil];
        return;
    }
    
    PickerToolView *picker = [[PickerToolView alloc]init];
    NSArray *data;
    if (sender==_btn1o) {
        data=ary1;
    }else if (sender==_btn3o)
    {
        data=ary2;
    }else if (sender==_btn4o)
    {
        data= ary3;
    }
    picker.dataSource = data;
    picker.didSelectItem = ^(NSInteger idx){

        [sender setTitle:data[idx] forState:UIControlStateNormal];
        
    };
    [picker showWithAnimation:YES];
    
}

-(void)ym_ymCitySelectCityName:(NSString *)cityName{
    
    [_btn2o setTitle:cityName forState:UIControlStateNormal];
    
}

@end
